package cc.wsyw126.java.collection.list;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;


/**
 * Created by yangdp on 16/8/31.
 */
public class TestLinkedList {
    public static void main(String[] args) {
        List list = new ArrayList();
        for (int i=0; i<10000; i++)
            list.add(i);
        TestBianli.iteratorThroughRandomAccess(list) ;
        LinkedList<Integer> linkedList = new LinkedList<>();
        for (int i=0; i<10000; i++)
            linkedList.add(i);
        iteratorThroughLinkedList(linkedList);
        iteratorThroughLinkedListOrder(linkedList);

    }

    public static void iteratorThroughLinkedList(LinkedList list) {

        long startTime;
        long endTime;
        startTime = System.currentTimeMillis();
        for (int i=0; i<list.size(); i++) {
            list.get(i);
        }
        endTime = System.currentTimeMillis();
        long interval = endTime - startTime;
        System.out.println("iteratorThroughLinkedList：" + interval+" ms");
    }

    public static void iteratorThroughLinkedListOrder(LinkedList<Integer> list) {

        long startTime;
        long endTime;
        startTime = System.currentTimeMillis();
        for (Integer i : list) {

        }
        endTime = System.currentTimeMillis();
        long interval = endTime - startTime;
        System.out.println("iteratorThroughLinkedListOrder：" + interval+" ms");
    }


}
